{ config, pkgs, lib, ... }:

let

  latex = pkgs.texlive.combine {
    inherit (pkgs.texlive) scheme-medium
      wrapfig capt-of preview lxfonts;
  };

  audio   = with pkgs; [ playerctl pulsemixer ];
  image   = with pkgs; [ feh sxiv imagemagickBig scrot ffmpeg ];
  library = with pkgs; [ zlib imlib2 libtool ];
  office  = with pkgs; [ poppler zathura ];
  themes  = with pkgs; [ gnome3.adwaita-icon-theme hicolor-icon-theme bibata-cursors-translucent ];
  utils   = with pkgs; [ stow htop neofetch zip unzip unrar bzip2 gzip xz ];
  video   = with pkgs; [ autorandr amdvlk vulkan-loader mpv youtube-dl ];
  x11     = with pkgs; [  xclip picom xorg.xset xorg.xsetroot xorg.xrdb
                          xorg.xmodmap xorg.xprop xorg.xrandr xorg.xfontsel ];
  
  devBase = with pkgs; [
    clang-tools
    gcc
    python3Packages.python-language-server
    python3Packages.pyls-isort
    python3Packages.flake8
    python3Packages.yapf
    python3Packages.biopython
    python3
    pandoc
    gnuplot
    graphviz
    latex
    R
    sqlite
    diffutils
    ag
    shellcheck
    lsof
    ltrace
    file
  ];

  nixTools = with pkgs; [
    nixpkgs-fmt nix-index nix-update
    nix-prefetch nix-template
    nix-zsh-completions
  ];

in

{
  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;
 
  home = {
    stateVersion = "21.03";
    username = "rxf4el";
    homeDirectory = "/home/rxf4el";
    keyboard = {
      layout = "br";
      variant = "abnt2";
      options = ["ctrl:nocaps"];
    };
  };
  
  xdg = {
    enable = true;
    mimeApps = {
      associations.added = {
        "x-scheme-handler/org-protocol" = [ "org-protocol.desktop" ];
      };
    };
  };

  home.packages = devBase ++ nixTools ++ audio ++ image
                  ++ library ++ office ++ themes
                  ++ utils ++ video ++ x11;
  
  # home.packages =
  #   with pkgs; [ playerctl
  #                pulsemixer
  #                htop neofetch
  #                gcc sqlite watchexec
  #                feh sxiv imagemagickBig ffmpeg scrot
  #                zlib imlib2 libtool libvterm
  #                poppler zathura
  #                hicolor-icon-theme
  #                zip unzip unrar bzip2
  #                autorandr mpv youtube-dl vulkan-loader amdvlk
  #                xorg.xset xorg.xsetroot xorg.xrdb xclip picom
  #                xorg.xmodmap xorg.xprop xorg.xrandr xorg.xfontsel ];
  
  programs = {
    emacs = {
      enable = true;
    };
    
    firefox = {
      enable = true;
    };
    
    git = {
      enable = true;
      userName = "rxf4el";
      userEmail = "rxf4e1@tuta.io";
    };
    
    fzf = {
      enable = true;
      enableBashIntegration = true;
      defaultOptions = [ "--color=bg+:24" ];
    };
    
  };
  
  services = {
    emacs.enable = true;
  };
  
  # xsession.pointerCursor = {
  #   package = pkgs.vanilla-dmz;
  #   name = "Vanilla-DMZ";
  # };
  
}
  
